<template>
  <div class="warp">
    <div class="card-list">
      <div class="card" v-for="item in datas" :key="item.wyid">
        <div class="spa1">
          <div>{{ item.wp }}</div>
          <div>{{ item.sl }}({{ item.dw }})</div>
        </div>
        <div class="spa2">
          <div class="d1">￥{{ item.je }}</div>
          <div class="d2">{{ item.pgrksj }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import store from "@/store/store";

export default {
  name: "Index",
  data() {
    return {
      pageNum: 1,
      pageSize: 20,
      pageCount: 0,
      datas: []
    };
  },
  computed: {
    companyId() {
      return store.state.companyId;
    }
  },
  methods: {
    getData() {
      const url = store.state.server + "/auth/getHistoryDd";
      this.mpvue.request({
        url: url,
        methods: "post",
        data: {
          wyid: this.companyId,
          pageSize: this.pageSize,
          pageNum: this.pageNum
        },
        success: res => {
          const { list, pager } = res.data;
          this.datas = list;
          this.pageCount = pager.pageCount;
        },
        fail: error => {
          uni.alert({
            content: error.errorMessage
          });
        }
      });
    }
  },
  onShow() {
    this.getData();
  },
  onReachBottom() {
    let pg = ++this.pageNum;
    if (pg <= this.pageCount) {
      this.getData();
    } else {
      this.pageNum--;
    }
  }
};
</script>

<style scoped lang="scss">
@import "../../common/common";

div {
  box-sizing: border-box;
}

.bs {
  margin: 10px 0;
}

.warp {
  display: flex;
  background-color: #e3e3e3;
  height: 100vh;
  width: 100vw;
  flex-direction: column;
  box-sizing: border-box;
  overflow: auto;
}
.card-list {
  background-color: #fff;
  padding: 20px 15px;
  .card {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
    .spa1 {
      display: flex;
      justify-content: space-between;
    }
    .spa2 {
      display: flex;
      align-items: center;
      justify-content: space-between;
      .d1 {
        font-size: 15px;
        color: gold;
        font-family: Calibri;
      }
      .d2 {
        color: #03a0de;
        font-size: 13px;
      }
    }
  }
}
</style>
